// HOC高阶组件

import { RootState } from "@/store";
import { ReactNode } from "react";
import { useSelector } from "react-redux";

export const Auth = (Node: ReactNode, roleList: Array<string>) => {
  // roleList  ['超级管理员','管理员','普通员工']
  //当前用户角色名称
  return function PermitAuth() {
    let { userInfo } = useSelector((state: RootState) => state.user);

    return <>{roleList.includes(userInfo!.roleData.roleName) ? Node : ""}</>;
  };
};
